﻿using GN.Pay.TradeChannel.DefaultImpl;
using GN.Pay.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel.Gyb.Response
{
    /// <summary>
    /// 查询响应
    /// </summary>
    [Serializable]
    class QueryResponse : AXmlResponse, ITradePayResult
    {
        public QueryResponse(string responseString,
            ITradeChannel channel,
            GybConfigure config) 
            : base(responseString, channel, config)
        {
        }

        /// <summary>
        /// 订单号
        /// </summary>
        public string TermSsn { get; set; }

        /// <summary>
        /// 交易金额
        /// </summary>
        public decimal TranAmt { get; set; }

        /// <summary>
        /// 完成状态
        /// <para>
        /// 00-交易成功
        /// 01-交易失败
        /// 02-撤消成功
        /// 03-部分退货
        /// 04-全部退货
        /// 05-预授权确认成功
        /// 06-预授权撤销补付成功
        /// 99-交易超时
        /// </para>
        /// </summary>
        public string CompFlag { get; set; }

        /// <summary>
        /// 清算日期
        /// </summary>
        public string SettDate { get; set; }

        /// <summary>
        /// 网关流水号
        /// </summary>
        public string AcqSsn { get; set; }

        /// <summary>
        /// 是否成功
        /// </summary>
        public override bool IsSuccess()
        {
            return base.IsSuccess() && "00".Equals(CompFlag);
        }

        /// <summary>
        /// 转为结果
        /// </summary>      
        /// <returns></returns>
        public ITradeOrderQueryResult ToResult()
        {
            return PayConvertUtils.ToPayResult(this, this.channel);
        }
    }
}
